package practice;

import java.util.*;

public class _09Last2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<String,Integer> map = new HashMap<>(7);
        map.put("Bessie",0);
        map.put("Elsie",0);
        map.put("Daisy",0);
        map.put("Gertie",0);
        map.put("Annabelle",0);
        map.put("Maggie",0);
        map.put("Henrietta",0);
        for (int i = 0;i < n;i++){
            String cow = scanner.next();
            Integer milk = scanner.nextInt();
            map.put(cow,map.get(cow) + milk);
        }
        scanner.close();
        //  找出产奶量第二少的奶牛，输出 key
        //  如果满足该条件的 key 不止一个或者没有的话，输出"Tie"
        List<Integer> list = new ArrayList(map.values());
        Collections.sort(list);
        if (list.get(0).equals(list.get(list.size() - 1))){
            System.out.println("Tie");
            return;
        }
        int milk = 0;
        for (int i = 1;i < list.size();i++){
            if (list.get(i).equals(list.get(i-1))){
                continue;
            }
            milk = list.get(i);
            if (i+1 < list.size() && list.get(i+1) == milk){
                System.out.println("Tie");
                return;
            }else {
                break;
            }
        }
        Set<String> set = new HashSet<>(map.keySet());
        for (String cow : set){
            if (map.get(cow) == milk){
                System.out.println(cow);
                break;
            }
        }
    }
}
